<%@ page language="java" pageEncoding="UTF-8"%>
<%

String filename=request.getParameter("fn");
filename = new String(filename.getBytes("iso8859-1"), "UTF-8");
filename = request.getRealPath("/") + "student_pic/" + filename;
java.io.File file = new java.io.File(filename);

if (file.exists()) {
	response.reset();
	filename = java.net.URLEncoder.encode(file.getName(), "UTF-8");
	response.setContentType("application/x-msdownload");
	response.addHeader("Content-Disposition", "attachment; filename=\"" + filename + "\"");
	int fileLength = (int) file.length();
	response.setContentLength(fileLength);
	java.io.InputStream inStream = new java.io.FileInputStream(file);
	byte[] buf = new byte[4096];
	ServletOutputStream servletOS = response.getOutputStream();
	int readLength;
	while (((readLength = inStream.read(buf)) != -1)) {
		servletOS.write(buf, 0, readLength);
	}
	inStream.close();
	servletOS.flush();
	servletOS.close();
	
	out.clear();
	out = pageContext.pushBody();
}

%>